<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>食堂每周菜品调查</title>
    <script src="http://wx.newamstar.com:8078/newstar/public/js/jquery.min.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>

    <script src="http://wx.newamstar.com:8078/newstar/public/js/layui.js"></script>
{{--    <link rel="stylesheet" href="http://wx.newamstar.com:8078/newstar/public/css/layui.css">--}}
</head>
<body>
<style>
    *{padding: 0px;margin: 0px;list-style: none}
    html,body{padding: 5px;}
    .checkbtn{
        display: inline-block;
        width: 14px; height: 14px;
        border: 1px solid #dcdfe6;
        border-radius: 3px;}

    input[type="checkbox"]:checked+span {
        background: #409eff;
        border: 1px solid #409eff;
    }
    .checkbtn:after {
        box-sizing: content-box;
        content: "";
        border: 2px solid #fff;
        border-left: 0;
        border-top: 0;
        width: 5px;
        height: 10px;
        position: absolute;
        top: 1px;
        left: 72px;
        transform: rotate(45deg) scaleY(0);
        transform-origin: center;
        transition: transform .15s ease-in .05s;
    }
    input[type="checkbox"]:checked+span::after {
        transform: rotate(45deg) scaleY(1);
    }
</style>
<div style="font-weight: bold;font-size: 16px;">
{{--    为了提升员工对食堂的满意度,--}}
    为了改善菜肴品质,现通过每周投票的方式筛选出员工喜欢的菜品,食堂会根据大家投票结果选择性提供,希望大家积极参与投票!(多选)
</div>
<div class="questions">
    <form id="form1">
    <ul>
        <li style="font-weight: bold;font-size: 16px;color: orangered">荤菜:</li>
        @foreach($list1 as $k => $v)
        <li>
            <div class="form-check">
                <label class="form-check-label">
                    <input type="checkbox" class="form-check-input" name="{{$v->cm}}" value="{{$v->type}}">{{$v->cm}}
                </label>
            </div>
        </li>
        @endforeach
        <li style="font-weight: bold;font-size: 16px;color: orangered">素菜:</li>
        @foreach($list2 as $k => $v)
            <li>
                <div class="form-check">
                    <label class="form-check-label">
                        <input type="checkbox" class="form-check-input" name="{{$v->cm}}" value="{{$v->type}}">{{$v->cm}}
                    </label>
                </div>
            </li>
        @endforeach
        <li style="font-weight: bold;font-size: 16px;color: orangered">汤:</li>
        @foreach($list3 as $k => $v)
            <li>
                <div class="form-check">
                    <label class="form-check-label">
                        <input type="checkbox" class="form-check-input" name="{{$v->cm}}" value="{{$v->type}}">{{$v->cm}}
                    </label>
                </div>
            </li>
        @endforeach
    </ul>
    </form>
{{--    <form id="form2">--}}
{{--        <ul>--}}
{{--            <li style="font-weight: bold;font-size: 16px;color: orangered">素菜:</li>--}}
{{--            @foreach($list2 as $k => $v)--}}
{{--                <li>--}}
{{--                    <div class="form-check">--}}
{{--                        <label class="form-check-label">--}}
{{--                            <input type="checkbox" class="form-check-input" name="{{$v->cm}}" value="{{$v->type}}">{{$v->cm}}--}}
{{--                        </label>--}}
{{--                    </div>--}}
{{--                </li>--}}
{{--            @endforeach--}}
{{--        </ul>--}}
{{--    </form>--}}
{{--    <form id="form3">--}}
{{--        <ul>--}}
{{--            <li style="font-weight: bold;font-size: 16px;color: orangered">汤:</li>--}}
{{--            @foreach($list3 as $k => $v)--}}
{{--                <li>--}}
{{--                    <div class="form-check">--}}
{{--                        <label class="form-check-label">--}}
{{--                            <input type="checkbox" class="form-check-input" name="{{$v->cm}}" value="{{$v->type}}">{{$v->cm}}--}}
{{--                        </label>--}}
{{--                    </div>--}}
{{--                </li>--}}
{{--            @endforeach--}}
{{--        </ul>--}}
{{--    </form>--}}
    <button type="button" class="btn btn btn-success" onclick="aaa()">提交问卷</button>
</div>
<script>
    function getFormJson(obj) {
        var o = {};
        var a = $(obj).serializeArray();
        $.each(a, function () {
            if (o[this.name] !== undefined) {
                if (!o[this.name].push) {
                    o[this.name] = [o[this.name]];
                }
                o[this.name].push(this.value || '');
            } else {
                o[this.name] = this.value || '';
            }
        });
        return o;
    }
    function extend(des, src, override){
        if(src instanceof Array){
            for(var i = 0, len = src.length; i < len; i++)
                extend(des, src[i], override);
        }
        for( var i in src){
            if(override || !(i in des)){
                des[i] = src[i];
            }
        }
        return des;
    }


    function aaa(){
       let json1 =  getFormJson("#form1");
       let json2 =  getFormJson("#form2");
       let json3 =  getFormJson("#form3");

        if(JSON.stringify(json1) == "{}"){
            layer.msg("请至少选择一个菜品")

        }else{
            if(JSON.stringify(json1) != "{}"){
                $.ajax({
                    url:"http://wx.newamstar.com:8078/newstar/public/add_cuisine",
                    type:"post",
                    data:json1,
                    success:function (res) {
                        console.log(res);
                    },
                    error:function (error) {
                        console.log(error);
                    }
                })
            }

            layer.msg("提交成功");
            window.location.href = "http://wx.newamstar.com:8078/newstar/public/end_cuisine"
        }



    }

</script>
</body>
</html>



